package com.hkyp.ss.course.apis.enumu;

import java.util.Objects;

/**
 * 投票枚举
 */
public enum ActionTypeEnum {
    UP("up",1),
    NEUTRAL("neutral",0),
    DOWN("down",-1);

    private Integer typeCode;
    private String typeName;

    ActionTypeEnum(String typeName, Integer typeCode) {
        this.typeCode = typeCode;
        this.typeName = typeName;
    }

    /**
     * 获取行为名称
     * @param id
     * @return
     */
    public static String getActionName(Integer id) {
        for (ActionTypeEnum c : ActionTypeEnum.values()) {
            if (Objects.equals(id,c.getTypeCode())) {
                return c.typeName;
            }
        }
        return null;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Integer getTypeCode() {
        return typeCode;
    }

    public void setTypeCode(Integer typeCode) {
        this.typeCode = typeCode;
    }
}
